= gitlab_ui_form_for [protected_branch_entity, @protected_branch], html: { class: 'new-protected-branch js-new-protected-branch' } do |f|
  %input{ type: 'hidden', name: 'update_section', value: 'js-protected-branches-settings' }

  = form_errors(@protected_branch)

  %h4.gl-mt-0= s_("ProtectedBranch|Protect a branch")

  .form-group.row
    = f.label :name, s_('ProtectedBranch|Branch:'), class: 'gl-col-sm-12'
    .gl-col-sm-12
      - if protected_branch_entity.is_a?(Group)
        = f.text_field :name, placeholder: 'prod*', class: 'form-control !gl-w-full gl-form-input-lg'
      - else
        = render partial: "protected_branches/shared/dropdown", locals: { f: f, toggle_classes: '!gl-w-full gl-form-input-lg' }
      .form-text.gl-text-subtle
        - wildcards_url = help_page_url('user/project/repository/branches/protected.md', anchor: 'use-wildcard-rules')
        - wildcards_link_tag_pair = tag_pair(link_to('', wildcards_url, target: '_blank', rel: 'noopener noreferrer'), :wildcards_link_start, :wildcards_link_end)

        - case_sensitive_url = help_page_url('user/project/repository/branches/protected.md', anchor: 'branch-names-are-case-sensitive')
        - case_sensitive_link_tag_pair = tag_pair(link_to('', case_sensitive_url, target: '_blank', rel: 'noopener noreferrer'), :case_sensitive_link_start, :case_sensitive_link_end)

        - code_tag_pair = tag_pair(tag.code, :code_tag_start, :code_tag_end)

        - if protected_branch_entity.is_a?(Group)
          = safe_format(s_('ProtectedBranch|Only %{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported. %{case_sensitive_link_start}Branch names are case-sensitive.%{case_sensitive_link_end}'), wildcards_link_tag_pair, case_sensitive_link_tag_pair, code_tag_pair)
        - else
          = safe_format(s_('ProtectedBranch|%{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported. %{case_sensitive_link_start}Branch names are case-sensitive.%{case_sensitive_link_end}'), wildcards_link_tag_pair, case_sensitive_link_tag_pair, code_tag_pair)
  .form-group.row
    = f.label :merge_access_levels_attributes, s_("ProtectedBranch|Allowed to merge:"), class: 'gl-col-sm-12'
    .gl-col-sm-12
      = yield :merge_access_levels
  .form-group.row
    = f.label :push_access_levels_attributes, s_("ProtectedBranch|Allowed to push and merge:"), class: 'gl-col-sm-12'
    .gl-col-sm-12
      = yield :push_access_levels
  .form-group.row
    = f.label :allow_force_push, s_("ProtectedBranch|Allowed to force push:"), class: 'gl-col-sm-12'
    .gl-col-sm-12
      = render Pajamas::ToggleComponent.new(classes: 'js-force-push-toggle',
        label: s_("ProtectedBranch|Allowed to force push"),
        label_position: :hidden) do
        - force_push_docs_url = help_page_url('topics/git/git_rebase.md', anchor: 'force-push-to-a-remote-branch')
        - force_push_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: force_push_docs_url }
        = (s_("ProtectedBranch|Allow all users with push access to %{tag_start}force push%{tag_end}.") % { tag_start: force_push_link_start, tag_end: '</a>' }).html_safe
  = render_if_exists 'protected_branches/ee/code_owner_approval_form', f: f, protected_branch_entity: protected_branch_entity
  = f.submit s_('ProtectedBranch|Protect'), disabled: true, data: { testid: 'protect-button', event_tracking: 'protect_branch', event_label: 'repository_settings' }, pajamas_button: true
  = render Pajamas::ButtonComponent.new(button_options: { type: 'reset', class: 'gl-ml-2 js-toggle-button' }) do
    = _('Cancel')
